{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import theano\n",
    "import theano.tensor as T\n",
    "import numpy\n",
    "from theano import function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Variables 'x' and 'y' are defined\n",
    "x = T.dscalar('x')\t\t\t\t\t# dscalar : Theano datatype\n",
    "y = T.dscalar('y')\n",
    "\n",
    "# 'x' and 'y' are instances of TensorVariable, and are of dscalar theano type\n",
    "print(type(x))\n",
    "print(x.type)\n",
    "\n",
    "print(T.dscalar)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 'z' represents the sum of 'x' and 'y' variables. \n",
    "# Theano’s pp function, pretty-print out, is used to display the computation of the variable 'z'\n",
    "z = x + y\n",
    "from theano import pp\n",
    "print(pp(z))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 'f' is a numpy.ndarray of zero dimensions, which takes input as the first argument, and output as the second argument\n",
    "# 'f' is being compiled in C code\n",
    "f = function([x, y], z)\t\t    \n",
    "\n",
    "#    The above created function could be used in the following manner to perform the addition operation : \n",
    "f(6, 10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "numpy.allclose(f(10.3, 5.4), 15.7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
